from django.contrib import admin
# 导入模型
from .models import SA_Info, Customers, Project, Task


# Register your models here.


class SA_InfoManager(admin.ModelAdmin):
    # 需要显示的字段 list_display
    list_display = ['Employee_No', 'SA_CName', 'SA_EName',
                    'Email', 'mobile', 'RO', 'role']
    # 哪些字段增加链接到修改页面
    list_display_links = ['Employee_No',]
    # 增加过滤器
    list_filter = ['RO', 'Status', 'role']
    # 添加搜索框
    search_fields = ['SA_CName', 'Employee_No']
    # 添加可以列表页编辑的字段
    list_editable = ['SA_CName', 'SA_EName',
                     'Email', 'mobile', 'RO', 'role']
    # 设置每页显示的记录条数为10
    list_per_page = 10


admin.site.register(SA_Info, SA_InfoManager)


class CustomersManager(admin.ModelAdmin):
    list_display = ['id', 'create_date', 'RO', 'name', 'status']
    list_display_links = ['id']
    list_filter = ['RO', 'status']
    search_fields = ['name', 'notes']
    list_editable = ['RO', 'name', 'status']
    # 设置每页显示的记录条数为10
    list_per_page = 10


admin.site.register(Customers, CustomersManager)


class ProjectManager(admin.ModelAdmin):
    list_display = ['id', 'SR_No', 'sa', 'customer', 'category', 'software',
                    'start_date', 'status',
                    ]
    list_display_links = ['id', 'SR_No']
    list_filter = ['software', 'actors', ]
    search_fields = ['customer', 'sa']
    list_editable = ['sa', 'customer', 'category', 'software',
                     'start_date', 'status',
                     ]
    # 设置每页显示的记录条数为10
    list_per_page = 10


admin.site.register(Project, ProjectManager)


class TaskManager(admin.ModelAdmin):
    list_display = ['id', 'project', 'creator', 'sub_number', 'task_number', 'task_date',
                    'start_time', 'end_time',
                    'overtime', 'task_server_num', 'task_mfd_num', 'task_printer_num',
                    'task_type', 'software_type']
    list_display_links = ['id']
    list_filter = ['creator']
    search_fields = ['project']
    list_editable = ['project', 'creator', 'sub_number', 'task_number', 'task_date',
                     'start_time', 'end_time',
                     'overtime', 'task_server_num', 'task_mfd_num', 'task_printer_num',
                     'task_type', 'software_type']
    list_per_page = 10


admin.site.register(Task, TaskManager)
